#include <iostream>
#include <memory>
#include "UdpServer.hpp"
#include "Dict.hpp"

// ./udpserver port
int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        std::cerr << "Usage: " << argv[0] << " port" << std::endl;
        return 1;
    }
    uint16_t port = (uint16_t)std::stoi(argv[1]);

    // 1.创建字典对象，加载
    Dict dict;
    dict.Load();

    // 2.创建服务端
    std::unique_ptr<UdpServer> udpserver = std::make_unique<UdpServer>(port, 
        [&dict](const std::string &english)->std::string{
            return dict.Translate(english);
    });

    // 3.启动服务端
    udpserver->Start();

    return 0;
}